<?php
session_start(); // always start session

if ($_SESSION['user'] != 'admin') {
    header('Location: login.php');
    exit();
}

require_once "config.php";

// update.php saves the data into a file, creates the file if it does not exist
if ($_POST) {
    $content = $_POST['content-text'];
    $title = $_POST['content-title'];
    $filename = $wikidir . "/" . $title . ".wiki";
    
    // just save it
    file_put_contents($filename, $content);
    
    // redirect back to index
    header('Location:index.php?f=' . $title);
    
}
